@echo off

setlocal EnableExtensions EnableDelayedExpansion

set logfile=C:\unpack-moviez-list.log
set unpack_script=%~dp0unpack-moviez.cmd

echo Log start: [!DATE! !TIME!] >!logfile!
for /f "delims=" %%m in (%~1) do (
    if not "%%~m"=="" (
        call !unpack_script! "%%m"
        if errorlevel 3 (
            echo INCOMPLETE: %%m>>!logfile!
        ) else if errorlevel 2 (
            echo    skipped: %%m>>!logfile!
        ) else if errorlevel 1 (
            echo      ERROR: %%m>>!logfile!
            set did_something=1
        ) else (
            echo       okay: %%m>>!logfile!
            set did_something=1
        )
    )
)
if not defined did_something echo NOTHING DONE... >>!logfile!
echo Log   end: [!DATE! !TIME!] >>!logfile!

start "" %WINDIR%\NOTEPAD.exe !logfile!

endlocal
